<template>
	<view class="content">
		<view class="app-title ac">
			<view class="fl" @click="back"><image class="back" src="/static/img/back.png"></image></view>器材扫码查询
		</view>
		
		<view class="top-bg"></view>
		
		<view class="detail">
			<u-cell-group>
				<view style="margin-bottom: 15px;"><b>器材信息</b></view>
				<u-cell-item title="所在机构:" :value="device.orgName" :arrow="false"></u-cell-item>
				<u-cell-item title="所在站:" :value="device.stationName" :arrow="false"></u-cell-item>
				<u-cell-item title="设备类型:" :value="device.eqtTypeName" :arrow="false"></u-cell-item>
				<u-cell-item title="器材型号:" :value="device.eqtModelNum" :arrow="false"></u-cell-item>
				<u-cell-item title="实际上道位置备注:" :value="device.note" :arrow="false"></u-cell-item>
				<u-cell-item title="条形码:" :value="device.zcCode" :arrow="false"></u-cell-item>
				<u-cell-item title="存放位置:" :value="device.storeAddress" :arrow="false"></u-cell-item>
				<u-cell-item title="入库时间:" :value="device.inStorageTime" :arrow="false"></u-cell-item>
				<u-cell-item title="生产厂家:" :value="device.manufacturer" :arrow="false"></u-cell-item>
			</u-cell-group>
			
			<view v-if="device.inUseEqtVo != null" style="margin: 20px 0;"><b>在用设备信息</b></view>
			<u-cell-group v-if="device.inUseEqtVo != null">
				<u-cell-item title="所在机构:" :value="device.inUseEqtVo.orgName" :arrow="false"></u-cell-item>
				<u-cell-item title="所在站:" :value="device.inUseEqtVo.stationName" :arrow="false"></u-cell-item>
				<u-cell-item title="上道设备类型:" :value="device.inUseEqtVo.eqtTypeName" :arrow="false"></u-cell-item>
				<u-cell-item title="上道设备位置:" :value="device.inUseEqtVo.storeAddress" :arrow="false"></u-cell-item>
				<u-cell-item title="器材型号:" :value="device.inUseEqtVo.eqtModelNum" :arrow="false"></u-cell-item>
				<u-cell-item title="条形码:" :value="device.inUseEqtVo.zcCode" :arrow="false"></u-cell-item>
				<u-cell-item title="器材上道时间:" :value="device.inUseEqtVo.sdTime" :arrow="false"></u-cell-item>
				<u-cell-item title="备注:" :value="device.inUseEqtVo.note" :arrow="false"></u-cell-item>
			</u-cell-group>
		</view>
		
		<button class="default-btn" @click="codeCheck">扫码</button>
		
		<view class="full" v-show="show_picker"></view>
		<u-select v-model="show_picker" :list="columns" label-name="text" @confirm="onConfirm" @cancel="onCancel"></u-select>
	</view>
</template>

<script>
export default{
	data() {
		return {
			device : '',
			device_attr : '',
			columns: [],
			data_list:{
				name:'',
				type:'请选择'
			},
			show_picker :false
		}
	},
	methods: {
		back() {
			uni.navigateBack();
		},
		onConfirm(value, index) {
			console.log(`当前值：${value}, 当前索引：${index}`);
			this.onCancel();
			if(index == 0) uni.navigateTo({url: '/pages/device/deiveAttr'});
			if(index == 1) uni.navigateTo({url: '/pages/alarm/historyAlarm'});
		},
		onCancel() {
			this.show_picker = false;
		},
		codeCheck() {
			 // 允许从相机和相册扫码
			uni.scanCode({
			    success: (res) => {
			        if(res) {
						this.fetch('GET',this.baseUrl()+'/eqtTZcController/scanCode',{action:'3',code:res.result}).then((res)=>{
							if(res.returnCode == 1) this.device = res.data;
						})
					}
				}
			});
		}
	}
}
</script>

<style scoped>
	.detail{
		height: auto;padding-top: 15px;
	}
	.default-btn{
		width: 91.5%;margin: 20px auto;
	}
</style>
